/*
 * Powered By cuichen
 * Since 2014 - 2017
 */package com.seeyoui.kensite.framework.cms.portlet.service;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.common.base.service.BaseService;

import java.util.*;

import com.seeyoui.kensite.common.base.domain.EasyUIDataGrid;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;
import com.seeyoui.kensite.common.util.*;
import com.seeyoui.kensite.common.constants.StringConstant;
import com.seeyoui.kensite.framework.cms.portlet.domain.Portlet;
import com.seeyoui.kensite.framework.cms.portlet.persistence.PortletMapper;

/**
 * Portlet
 * @author cuichen
 * @version 2.0
 * @since 1.0
 * @date 2017-12-27
 */

@Service
public class PortletService extends BaseService {
	
	@Autowired
	private PortletMapper portletMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public Portlet findOne(String id) throws CRUDException{
		return portletMapper.findOne(id);
	}
	
	/**
	 * 查询数据集合
	 * @param portlet
	 * @return
	 * @throws CRUDException
	 */
	public List<Portlet> findList(Portlet portlet) throws CRUDException {
		return portletMapper.findList(portlet);
	}
	
	/**
	 * 查询所有数据集合
	 * @param portlet
	 * @return
	 * @throws CRUDException
	 */
	public List<Portlet> findAll(Portlet portlet) throws CRUDException {
		return portletMapper.findAll(portlet);
	}
	
	/**
	 * 查询数据总数
	 * @param portlet
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(Portlet portlet) throws CRUDException {
		return portletMapper.findTotal(portlet);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param portlet
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(Portlet portlet) throws CRUDException {
		return portletMapper.findExTotal(portlet);
	}
	
	/**
	 * 数据新增
	 * @param portlet
	 * @throws CRUDException
	 */
	public void save(Portlet portlet) throws CRUDException{
		portlet.preInsert();
		portletMapper.save(portlet);
	}
	
	/**
	 * 数据修改
	 * @param portlet
	 * @throws CRUDException
	 */
	public void update(Portlet portlet) throws CRUDException{
		portlet.preUpdate();
		portletMapper.update(portlet);			
	}
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		portletMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param portlet
	 * @throws CRUDException
	 */
	public void remove(Portlet portlet) throws CRUDException{
		portlet.preUpdate();
		portletMapper.remove(portlet);			
	}
	
}